//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

namespace Microsoft.Research.ScientificWorkflow.TridentModelSL
{
    using System;
    using service = Microsoft.Research.ScientificWorkflow.TridentSilverlightService;

    /// <summary>
    /// Respresents a node in the tree veiw
    /// </summary>
    public class JobDetails
    {
        private string jobName;
        private Guid jobId;
        private string errormessage;
        private bool isdeleted;
        private string notes;
        private JobStatus status;

        /// <summary>
        /// Initializes a new instance of the <see cref="JobDetails"/> class.
        /// </summary>
        /// <param name="source">The source.</param>
        public JobDetails(service.JobDetails source)
        {
            this.JobId = source.jobId;
            this.JobName = source.jobName;
            this.JobName = source.jobName;
            this.ErrorMessage = source.errormessage;
            this.IsDeleted = source.isdeleted;

            try
            {
                this.Status = (JobStatus)Enum.Parse(typeof(JobStatus), source.status.ToString(), true);
            }
            catch (Exception)
            {
            }
        }

        /// <summary>
        /// Gets or sets the job id.
        /// </summary>
        /// <value>The job id.</value>
        public Guid JobId
        {
            get
            {
                return jobId;
            }
            set
            {
                jobId = value;
            }
        }

        /// <summary>
        /// Gets or sets the name of the job.
        /// </summary>
        /// <value>The name of the job.</value>
        public string JobName
        {
            get
            {
                return jobName;
            }
            set
            {
                jobName = value;
            }
        }

        /// <summary>
        /// Gets or sets the error message.
        /// </summary>
        /// <value>The error message.</value>
        public string ErrorMessage
        {
            get
            {
                return errormessage;
            }
            set
            {
                errormessage = value;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this <see cref="JobDetails"/> is isdeleted.
        /// </summary>
        /// <value><c>true</c> if isdeleted; otherwise, <c>false</c>.</value>
        public bool IsDeleted
        {
            get
            {
                return isdeleted;
            }
            set
            {
                isdeleted = value;
            }
        }

        /// <summary>
        /// Gets or sets the notes.
        /// </summary>
        /// <value>The notes.</value>
        public string Notes
        {
            get
            {
                return notes;
            }
            set
            {
                notes = value;
            }
        }

        /// <summary>
        /// Gets or sets the status.
        /// </summary>
        /// <value>The status.</value>
        public JobStatus Status
        {
            get
            {
                return status;
            }
            set
            {
                status = value;
            }
        }
    }

    /// <summary>
    /// 
    /// </summary>
    public enum JobStatus
    {
        /// <summary>
        /// 
        /// </summary>
        NotStarted,
        /// <summary>
        /// 
        /// </summary>
        Initializing,
        /// <summary>
        /// 
        /// </summary>
        Running,
        /// <summary>
        /// 
        /// </summary>
        Paused,
        /// <summary>
        /// 
        /// </summary>
        Waiting,
        /// <summary>
        /// 
        /// </summary>
        Completed,
        /// <summary>
        /// 
        /// </summary>
        Aborted,
        /// <summary>
        /// 
        /// </summary>
        StartPending,
        /// <summary>
        /// 
        /// </summary>
        StopPending,
        /// <summary>
        /// 
        /// </summary>
        PausePending,
        /// <summary>
        /// 
        /// </summary>
        ResumePending,
    }
}
